package iofile;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class BufferedReader_ {

    public static void main(String[] args) {

        String filePath = "";
        BufferedReader bufferedReader = null;
        try {
            //创建BufferedReader对象时，传入一个Reader的子类，作为封装在里层的节点流
            bufferedReader = new BufferedReader(new FileReader(filePath));
            String line;
            //按行读取，读取到文件末尾时，返回null
            while((line = bufferedReader.readLine()) != null){
                System.out.println(line);
            };
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                //只需要关闭外层的处理流，底层会自动关闭封装的节点流
                bufferedReader.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }


}
